const app = getApp()
Component({
  properties: {
    navigationBarTitle: {
      type: String,
      value: ''
    },
    back: {
      type: Boolean,
      value: false
    },
    custom:{
      type:Boolean,
      value:false
    },
    home: {
      type: Boolean,
      value: false
    },
    black: {
      type: Boolean,
      value: true
    },
    person: {
      type: Boolean,
      value: false
    },
    backgroundColor: {
      type: String,
      value: ''
    },
    borderColor: {
      type: String,
      value: ''
    },
    titleColor: {
      type: String,
      value: ''
    },
    nameColor: {
      type: String,
      value: ''
    },
    isNeed: {
      type: Boolean,
      value: true
    }
  },

  data: {
    statusBarHeight: app.globalData.statusBarHeight,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    url:"",
    name:"个人中心"
  },
  lifetimes: {
    attached: function () {
    },
  },
  methods: {
    backHome: function() {
      wx.reLaunch({
        url: '/pages/index/index',
      })
    },
    back: function() {
      if (!this.data.custom)
      wx.navigateBack({
        delta: 1
      })
      else{
        this.triggerEvent('back')
      }
    },
    changeStatus(){
      app.globalData.userInfo.avatarUrl && wx.navigateTo({
        url:"/pages/personal/personal"
      })
    },
    bindGetUserInfo(e) {
      app.getUserInfo(e).then(user=>{
        this.setData({
          avatarUrl: user.avatarUrl,
          nickName: user.nickName
        })
        app.globalData.userInfo.nickName=user.avatarUrl
        app.globalData.userInfo.avatarUrl=user.nickName
        wx.switchTab({
          url:"/pages/personal/personal"
        })
      })

    },
  }
})
